﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("欢迎使用扫码枪2");
            textBox1.Focus();      //为控件设置输入焦点
        }

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            //捕获回车键
            if (e.KeyCode == Keys.Enter)
            {
                //获取条码资料
                string barcode = textBox1.Text.Trim();

                if (!String.IsNullOrEmpty(barcode))
                {
                    //条码处理程序
                    MessageBox.Show($"222222处理后的条形码：{barcode}");
                }
            }
        }
    }
}
